<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {
    public function index(){
	$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>！</p></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
    }

	public function cache(){
		dump(D('Public')->getCache());
	}

	public function tryNull(){
		$openid = 'ow4A3vwWHybf-lN4xCE2r9r4TRKk';
		$data = M('WangkaBindView')->where('openid="'.$openid.'"')->find();
		dump($data);
		echo '<hr />';
		if(is_null($data['mobile'])) echo 'NULL';
		else echo 'Not Null';
		echo '<hr />';
		if(is_null($data['nickname'])) echo 'Null';
		else echo $data['nickname'];
	}

	public function md(){
		echo APP_URL.U('Business/Index', array('an' => 'createShop'));
	}

	public function pushMsg(){
		$url = 'http://wx.mywoka.com'.U('Api/pushTemplateMsg');
		$postdata = array(
			'weixin'        => 'WKSHOP',
			'type'          => 'confirm',
			'app_primary'   => md5('order_sn:00001'),
			'wz_primary'    => '1',
			'mobile'        => '13354631875',
			'money'         => '386.00',
		);
		Vendor('Snoopy');
		$Snoopy = new Snoopy();
		$Snoopy->submit($url, $postdata);
		$data = $Snoopy->results;
		if($data)
			return json_encode($data);
		else
			echo "<br/>请求失败！<br/>";
	}

	public function send(){
		header("Content-type: json; charset=utf-8");
		Vendor('Weixin');
		$weixin = new Weixin('WKSHOP');
		$url = APP_URL.U('Business/index', array('an' => 'onePage', 'type' => 'confirm'));
		$data = array(
			'first'     => array('value' => '尊敬的商户【刘鲲野鸡店】您好，您有一个订单正等待您的确认: ', 'color' => '#173177'),
			'keyword1'  => array('value' => 'YN-waka-'.time(), 'color' => '#173177'),
			'keyword2'  => array('value' => '汪卡APP支付', 'color' => '#173177'),
			'keyword3'  => array('value' => '￥998', 'color' => '#173177'),
			'remark'    => array('value' => '欢迎使用【汪卡在线】商户服务系统, 请点击详情进行交易确认!', 'color' => '#ef2323')
		);
		echo $weixin->send_template_message('oNA3Tvst10EWgiT6hKEjLujS3uG0', '0PXztJoSMtqzz3UGem3N6KJ8YeYgILrQB4-qFW6z2_4', $data, $url);
	}

	public function test(){
		echo 'Logic';
		dump(D('Register', 'Logic')->test());
		echo 'Event';
		dump(A('Register', 'Event')->dddd());
		//$this->ajax(D('Register', 'Logic')->test());
	}
}